﻿@{
    ViewBag.Title = "CreateMonthly";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model DepartmentWork.Model.MonthlyViewModel
<link href="~/Assets/plugins/bootstrap-treeview/css/bootstrap-treeview.css" rel="stylesheet" />
<script src="~/Assets/plugins/bootstrap-treeview/js/bootstrap-treeview.js"></script>
<style>
   ul>.active {
       font-weight:bold
   }

   #wizard2 ul>.active {
       font-weight:bold
   }
</style>
<script>
    function ShowParentXiangMu(index)
    {
        if ($("#treeview_XiangMu li[data-nodeid='XiangMu_" + index + "']").css('display') == 'block')
        {
            $("#treeview_XiangMu li[data-nodeid='XiangMu_" + index + "']").hide(300);
            $("#span_XiangMu_" + index).attr('class', 'icon expand-icon glyphicon glyphicon-plus');
        }
        else
        {
            $("#treeview_XiangMu li[data-nodeid='XiangMu_" + index + "']").show(300);
            $("#span_XiangMu_" + index).attr('class', 'icon expand-icon glyphicon glyphicon-minus');
        }

    }
</script>

<script>
    function ShowParentYunWei(index)
    {
        if ($("#treeview_YunWei li[data-nodeid='YunWei_" + index + "']").css('display') == 'block')
        {
            $("#treeview_YunWei li[data-nodeid='YunWei_" + index + "']").hide(300);
            $("#span_YunWei_" + index).attr('class', 'icon expand-icon glyphicon glyphicon-plus');
        }
        else
        {
            $("#treeview_YunWei li[data-nodeid='YunWei_" + index + "']").show(300);
            $("#span_YunWei_" + index).attr('class', 'icon expand-icon glyphicon glyphicon-minus');
        }

    }


</script>

<div class="page-header">
    <div class="pull-left">
        <ol class="breadcrumb visible-sm visible-md visible-lg">
            <li><a href="@Url.Action("Index", "Home", new { area = "" })"><i class="icon fa fa-home"></i>主页</a></li>
            <li><a href="@Url.Action("Index", "Project", new { area = "ProjectManageArea" })"><i class="fa fa-envelope"></i>项目模块</a></li>
            <li><a href="@Url.Action("Index", "Project", new { area = "ProjectManageArea", projectId = ViewBag.ProjectId })"><i class="fa fa-envelope"></i>项目详情</a></li>
            <li class="active"><a href="#"><i class="fa fa-envelope"></i>月报</a></li>
        </ol>
    </div>
</div>


@{
    if (ViewBag.flag == "CreateTrue")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;月报添加成功！</strong>
    </div>
    }
    if (ViewBag.flag == "CreateFalse")
    {
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;月报添加失败！</strong> @ViewBag.Info
    </div>
    }
    if (ViewBag.flag == "ExecuteTrue")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;月报生成成功！</strong>
    </div>
    }
    if (ViewBag.flag == "ExecuteTrue")
    {
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;月报生成失败！</strong> @ViewBag.Info
    </div>
    }

    if (ViewBag.flag == "DelTrue")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;月报删除成功！</strong>
    </div>
    }

    if (ViewBag.flag == "DelFalse")
    {
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;月报删除失败！</strong> @ViewBag.Info
    </div>
    }
}


<div class="panel">
    <div class="panel-heading bk-bg-primary">
        <h6><i class="fa fa-table red"></i><span class="break"></span>@ViewBag.ProjectName 项目月报</h6>
        <div class="panel-actions">
         

        </div>
    </div>
    <div class="panel-body">

        <div class="tabs">
            <ul class="nav nav-tabs">
                <li class="">
                    <a style="color:black" href="@Url.Action("Index","Monthly",new{area="ProjectManageArea"})" >月报查询</a>
                </li>
                <li class="active">
                    <a style="color:black" href="#" data-toggle="tab">月报生成</a>
                </li>
                <li class="">
                    <a style="color:black" href="#overview" data-toggle="tab">上传月报</a>
                </li>
            </ul>
            <div class="tab-content">

                <div id="" class="tab-pane updateProfile">
                </div>

                <div id="edit" class="tab-pane  active">
                    <form method="POST" id="frm_ExecuteMonthly" action="@Url.Action("ExecuteCreateMonthly", "Monthly", new { area = "ProjectManageArea" })">

                        <div class="panel-body">
                            <div id="wizard2" class="wizard-type2">
                                <ul  id="wizard_ul" class="steps nav nav-pills">
                                    <li  id="li_0" style="color:black;" class="active"><a id="a_00" style="font-size: 15px;color:black" href="#tab21" data-toggle="tab"><span class="badge badge-info"></span>选择月报期数 &emsp;&emsp;  > </a></li>
                                    <li  id="li_1" style="color:lightslategrey" class=""><a id="a_01" style="font-size: 15px;color:black" href="#tab22" data-toggle="tab"><span class="badge badge-info"></span>选择工作记录并生成月报</a></li>
                                </ul>

                                <div id="div_content" class="tab-content">
                                    <div class="tab-pane active" id="tab21">
                                        <div class="row">
                                            <div class="form-group col-sm-4">
                                                <label for="ccyear-w2">选择年份：</label>
                                                <select name="select_year" class="form-control" id="select_year">
                                                    <option value="0">请选择</option>
                                                    <option value="2017">2017</option>
                                                    <option value="2018">2018</option>
                                                    <option value="2019">2019</option>
                                                    <option value="2020">2020</option>
                                                    <option value="2021">2021</option>
                                                    <option value="2022">2022</option>
                                                    <option value="2023">2023</option>
                                                    <option value="2024">2024</option>
                                                    <option value="2025">2025</option>
                                                </select>
                                            </div>

                                            <div class="form-group col-sm-4">
                                                <label for="ccmonth-w2">选择月份：</label>
                                                <select name="select_month"  class="form-control" id="select_month">
                                                    <option value="0">请选择</option>
                                                    <option value="1">1</option>
                                                    <option value="2">2</option>
                                                    <option value="3">3</option>
                                                    <option value="4">4</option>
                                                    <option value="5">5</option>
                                                    <option value="6">6</option>
                                                    <option value="7">7</option>
                                                    <option value="8">8</option>
                                                    <option value="9">9</option>
                                                    <option value="10">10</option>
                                                    <option value="11">11</option>
                                                    <option value="12">12</option>
                                                </select>
                                            </div>
                                        </div>

                                    </div>
                                    <div class="tab-pane" id="tab22">
                                        
                                        <div id="div_ErrMsg" class="alert alert-danger" style="display: none">
                                            <button type="button" class="close" data-dismiss="alert">×</button>
                                            <strong>&emsp;请选择工作记录！</strong> 
                                        </div>

                                        <h4><label>请选择项目所对应的工作记录：</label></h4>
                                        <h5><label>项目管理</label></h5>
                                        <div id="treeview_XiangMu" class="treeview">
                                            <ul class="list-group">

                                                @{
                                                    for (int i = 0; i < this.Model.ProjectManagementList.Count(); i++)
                                                    {
                                                        <li class="list-group-item node-treeview" onclick="ShowParentXiangMu(@i)">
                                                            <span id="span_XiangMu_@i" class="icon expand-icon glyphicon glyphicon-plus"></span>
                                                            <span class="icon node-icon"></span>
                                                            @this.Model.ProjectManagementList[i].PROJECT_MANAGEMENT_TITLE
                                                        </li>
                                                        for (int j = 0; j < this.Model.ProjectWorkReocredList.Count(); j++)
                                                        {
                                                            if (this.Model.ProjectWorkReocredList[j].PROJECT_MANAGEMENT_ID == this.Model.ProjectManagementList[i].PROJECT_MANAGEMENT_ID)
                                                            {
                                                                <li class="list-group-item node-treeview" style="display: none"  data-nodeid="XiangMu_@i">
                                                                    <span class="indent"></span>
                                                                    <span class="icon">
                                                                        <input type="checkbox" id="Pro_@this.Model.ProjectWorkReocredList[j].PROJECT_WORKRECORD_ID" name="ck_AllProject" value="Pro_@this.Model.ProjectWorkReocredList[j].PROJECT_WORKRECORD_ID"/>
                                                                    </span>
                                                                    <span class="icon node-icon"></span>
                                                                    @this.Model.ProjectWorkReocredList[j].PROJECT_WORKRECORD_TITLE
                                                                    &emsp;&emsp;
                                                                    @this.Model.ProjectWorkReocredList[j].PROJECT_WORKRECORD_CREATETIME.ToString("yyyy-MM-dd")
                                                                </li>
                                                            }
                                                        }
                                                    }
                                                }
                                            </ul>
                                        </div>

                                        <h5><label>运维管理</label></h5>

                                        <div id="treeview_YunWei" class="treeview">
                                            <ul class="list-group">
                                                @{
                                                    for (int i = 0; i < this.Model.ProjectManitenanceAppopsList.Count(); i++)
                                                    {
                                                        <li class="list-group-item node-treeview" onclick="ShowParentYunWei(@i)">
                                                            <span id="span_YunWei_@i" class="icon expand-icon glyphicon glyphicon-plus"></span>
                                                            <span class="icon node-icon"></span>
                                                            @this.Model.ProjectManitenanceAppopsList[i].appops_name
                                                        </li>
                                                        for (int j = 0; j < this.Model.ProjectManitenanceRecordList.Count(); j++)
                                                        {
                                                            if (this.Model.ProjectManitenanceRecordList[j].record_operation_id == this.Model.ProjectManitenanceAppopsList[i].appops_id)
                                                            {
                                                                <li class="list-group-item node-treeview" style="display: none" data-nodeid="YunWei_@i">
                                                                    <span class="indent"></span>
                                                                    <span class="icon">
                                                                        <input type="checkbox" id="YunWei_@this.Model.ProjectManitenanceRecordList[j].record_id" name="ck_AllProject" value="YunWei_@this.Model.ProjectManitenanceRecordList[j].record_id"/>
                                                                    </span>
                                                                    <span class="icon node-icon"></span>
                                                                    @this.Model.ProjectManitenanceRecordList[j].record_name
                                                                    &emsp;&emsp;
                                                                    @this.Model.ProjectManitenanceRecordList[j].record_time.ToString("yyyy-MM-dd")
                                                                </li>
                                                            }
                                                        }
                                                    }
                                                }

                                            </ul>
                                        </div>

                                    </div>
                                    <div class="actions">
                                        <input id="btn_Over" onclick="ShowOver()" class="btn btn-info button-previous" name="previous" value="上一步" type="button">
                                        <input id="btn_Next" onclick="ShowNext()" style="display: block;" class="btn btn-primary button-next pull-right" name="next" value="下一步" type="button">
                                        @{
                                            if (ViewBag.IsAdmin)
                                            {
                                                <a style="display:none" id="a_UpLoadMonthly" data-toggle="modal" data-target="#myModal" class="bk-margin-5 btn btn-default  btn-sm" style="background-color: #ECEDF0">&nbsp;&nbsp;上传月报&nbsp;&nbsp;</a>
                                            }
                                        }
                                        <input class="btn btn-success button-finish pull-right" name="finish" value="Finish" style="display: none;" type="button">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                
                <div id="overview" class="tab-pane updateProfile">
                                        <div class="col-sm-12">
                        <form method="POST" enctype="multipart/form-data" action="@Url.Action("CreateMonthly", "Monthly", new { area = "ProjectManageArea" })">
                            <div class="modal-body">
                                <div class="row">
                                    <input type="hidden" name="hid_ProjectId" value="@ViewBag.ProjectId"/>
                                    <div class="form-group col-sm-4">
                                        <label for="ccyear-w2">选择年份：</label>
                                        <select name="select_year" class="form-control" id="ccyear-w2">
                                            <option value="2017">2017</option>
                                            <option value="2018">2018</option>
                                            <option value="2019">2019</option>
                                            <option value="2020">2020</option>
                                            <option value="2021">2021</option>
                                            <option value="2022">2022</option>
                                            <option value="2023">2023</option>
                                            <option value="2024">2024</option>
                                            <option value="2025">2025</option>
                                        </select>
                                    </div>

                                    <div class="form-group col-sm-4">
                                        <label for="ccmonth-w2">选择月份：</label>
                                        <select name="select_month"  class="form-control" id="ccmonth-w2">
                                            <option value="1">1</option>
                                            <option value="2">2</option>
                                            <option value="3">3</option>
                                            <option value="4">4</option>
                                            <option value="5">5</option>
                                            <option value="6">6</option>
                                            <option value="7">7</option>
                                            <option value="8">8</option>
                                            <option value="9">9</option>
                                            <option value="10">10</option>
                                            <option value="11">11</option>
                                            <option value="12">12</option>
                                        </select>
                                    </div>

                                    <div class="form-group col-sm-4">
                                        <label for="tb_DocumentFile">文档：</label>
                                            <input  id="tb_DocumentFile" style="border-color: cornflowerblue;width: 100%" name="tb_MonthlyFileName" class="form-control" placeholder="文件展示名" type="file">
                                    </div>

                                </div>
                                <br />

                            </div>
                            <div class="modal-footer">

                                <input onclick=" CheckUpLoadMonthly()" type="button" class="btn btn-primary" value="上传" />
                            </div>
                        </form>

                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
<script>
    function ShowNext()
    {
        if ($("#select_year").val() == "0" || $("#select_month").val()=="0") {
            return false;
        }


        $("#li_1").attr("class", "active");
        $("#tab22").attr("class", "tab-pane active");
        $("#a_01").css("color", "black");
        $("#a_00").css("color", "lightslategrey");
        $("#li_0").attr("class", "");
        $("#tab21").attr("class", "tab-pane");

        $("#btn_Over").attr("class", "btn btn-info button-previous");
        
        if ($("#btn_Next").val() == "完成" && $("#frm_ExecuteMonthly input[type=checkbox]:checked").length == 0)
        {
            $("#div_ErrMsg").show();
        }
        
        $("#btn_Next").val("完成");

        $("#a_UpLoadMonthly").css("display", "block");

        if ($("#btn_Next").val()=="完成"&& $("#frm_ExecuteMonthly input[type=checkbox]:checked").length != 0)
        {
            $("#frm_ExecuteMonthly").submit();
        }

    }

    function ShowOver()
    {
        $("#li_0").attr("class", "active");
        $("#tab21").attr("class", "tab-pane active");
        $("#a_01").css("color", "lightslategrey");
        $("#a_00").css("color", "black");
        $("#li_1").attr("class", "");
        $("#tab22").attr("class", "tab-pane");
        $("#btn_Next").val("下一步");
        $("#btn_Over").attr("class", "btn btn-info button-previous disabled");
    }

</script>

<script>
    function CheckUpLoadMonthly()
    {
        var msg = "";
        if ($("#frm_UpLoadMonthly #select_year").val() == "")
        {
            msg += "·月报年份不能为空 <br/>";
        }
        if ($("#frm_UpLoadMonthly #select_month").val() == "")
        {
            msg += "·月报月份不能为空 <br/>";
        }
        if ($("#frm_UpLoadMonthly #tb_DocumentFile").val() == "")
        {
            msg += "·月报文件不能为空 <br/>";
        }
        if (msg != "")
        {
            $("#div_CheckUpLoadMonthlyMessage").css("display", "block");
            $("#lb_CheckUpLoadMonthlyMessage").html(msg);
            return false;
        } else
        {
            $("#frm_UpLoadMonthly").submit();
        }
    }
</script>



